package day14.KeJian;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class MyCallable01 implements Callable<String> {

    @Override
    public String call() throws Exception {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName()+"----"+i);
        }
        return "线程执行完毕了";    }
}
class Demo02{
    public static void main(String[] args) {
        //优先级: 1 - 10 默认值:5
        MyCallable01 mc = new MyCallable01();
        FutureTask<String> ft = new FutureTask<>(mc);
        Thread t1 = new Thread(ft);
        t1.setName("飞机");
        t1.setPriority(10);
        t1.start();

        MyCallable01 mc2 = new MyCallable01();
        FutureTask<String> ft2 = new FutureTask<>(mc2);
        Thread t2 = new Thread(ft2);
        t2.setName("坦克");
        t2.setPriority(1);
        t2.start();
    }
}
